package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: twer
 * Date: 5/21/13
 * Time: 9:05 PM
 * To change this template use File | Settings | File Templates.
 */
public class Library {
    private List<String> books;
    private List<Movie> movies;

    public Library() {

        books = new ArrayList<String>();
        movies = new ArrayList<Movie>();
    }

    public List<String> books() {
        return books;
    }

    public void addBook(String book){
        books.add(book);
    }


    public boolean hasBook(String book) {
        return books.contains(book);
    }

    public void addMovie(Movie movie) {
        movies.add(movie);
    }

    public int countOfMovies() {
        return movies.size();
    }

    public List<Movie> movies() {
        return movies;
    }


    public String moviesAppearance() {
        StringBuilder result = new StringBuilder();
        result.append(movieListHeader());
        result.append("\n");
        for (Movie movie : movies){
            result.append(movie.toString());
            result.append("\n");
        }
        return result.toString();
    }


    public String booksMessage(){
        StringBuilder builder = new StringBuilder();
        for(String book : books){
            builder.append(book);
            builder.append("\n");
        }
        return builder.toString();
    }

    public String movieListHeader() {
        return "Movie\t\t\t\tYear\tDirector\t\t\tRating";
    }


    public String reserveBookFor(String book, Reader reader) {
        if (hasBook(book) == false){
            return "Sorry we don't have that book yet.";
        }
        if (hasBeenReserved(book)){
            return "Sorry, the book have been reserved already.";
        }
        reserveBook(book, reader);
        return "Thank You! Enjoy the book.";
    }

    private void reserveBook(String book, Reader reader) {

    }

    private boolean hasBeenReserved(String book) {
        return false;  //To change body of created methods use File | Settings | File Templates.
    }
}
